<template>
  <div>
    <a-modal v-model="visible" title="评标记录" :footer="null" :width="800">
      <a-table rowKey="id" bordered size="middle" :columns="columns" :dataSource="list" :pagination="false">
        <div slot="completeStatus" slot-scope="text, record">
          <template v-if="record.completeStatus == null">
            未设置
          </template>
          <template v-else>
            {{ record.completeStatus == '1' ? '已完成' : record.completeStatus == '0'?'未完成':'已驳回' }}
          </template>

        </div>
        <div slot="action" slot-scope="text, record">
          <a-button v-if="record.completeStatus == '1'" @click="showRejectModal(record)" type="link">退回编辑</a-button>
        </div>
      </a-table>
    </a-modal>
    <a-modal v-model="rejectVisible" title="退回" :width="800" @ok="changeStatus">
      <a-input v-model="rejectForm.rejectRemark" placeholder="请输入退回原因"/>
    </a-modal>
  </div>
</template>

<script>
import { getAction, postAction } from '@api/manage'

export default {
  name: 'PingBiaoExpertRecord',
  components: {},
  props: {},
  data () {
    return {
      visible: false,
      columns: [
        {
          title: '专家名称',
          align: 'center',
          dataIndex: 'expertName'
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'completeStatus',
          scopedSlots: { customRender: 'completeStatus' }
        },
        {
          title: '操作',
          align: 'center',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' }
        }],
      list: [],
      url:{
        queryExpertRecord: '/exPingbiao/exPingbiaoExpert/queryRecord',
        backEdit:'/exPingbiao/exPingbiaoExpert/backEdit'
      },
      sectionId:null,
      tenderListId:null,
      rejectVisible: false,
      rejectForm:{
        id:null,
        rejectRemark: '',
      }
    }
  },

  computed: {},
  methods: {
    showModal (sectionId,tenderListId) {
      this.visible = true
      this.sectionId= sectionId;
      this.tenderListId = tenderListId;
      this.queryExpertRecord();
    },
    queryExpertRecord () {
      getAction(this.url.queryExpertRecord, { sectionId:this.sectionId,tenderListId:this.tenderListId })
        .then((res) => {
          if (res.success && res.result) {
            this.list = res.result
          }
        })
        .finally(() => {})
    },
    showRejectModal (item) {
      this.rejectForm.id = item.id
      this.rejectVisible = true
    },
    changeStatus(){
      postAction(this.url.backEdit, this.rejectForm)
        .then((res) => {
          if (res.success) {
            this.$message.success('回退成功');
            this.rejectVisible = false
            this.queryExpertRecord()
            this.$emit('refresh')
          }
        })
        .finally(() => {})
    }
  },
  created () {
  }
}
</script>

<style scoped>
</style>
